function test() {
    let age

    function setage(v) {
        if (typeof v === 'number') {
            if (v > 0 && v <= 100) {
                age = v
            } else {
                age = 20
            }
        } else {
            age = 20
        }
    }

    function getage() {
        return age
    }

    return {
        setage,
        getage
    }
}

let obj = test()
obj.setage(400)
console.log(obj.getage())